﻿using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using Simple.Http;
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using ConsoleApp.CheckTest;
using Simple.Tools.SnowFlake;
using System.Collections.Generic;
using System.Linq;
using Simple.Entity.View;
using Simple.Tools;
using ConsoleApp.TestSecurity;
using ConsoleApp.IDWork;

namespace ConsoleApp
{
    public class Program
    {
        static void Main(string[] args)
        {
   //         HttpTest.TestUap();

			//MapTest mapTest = new MapTest();
			//mapTest.TestMapTo();

   //         Console.WriteLine("A");


   //         IdTest.Test();

			//Console.WriteLine(Worker.GetId(DateTime.Now.AddYears(10)));
   //         Console.WriteLine(Worker.GetId(DateTime.Now.AddYears(10)));
   //         Console.WriteLine(Worker.GetId(DateTime.Now.AddYears(10)));
   //         Console.WriteLine(Worker.GetId(DateTime.Now.AddYears(10)));

			//MyClass myClass1 = new MyClass();

			//Console.WriteLine(JsonConvert.SerializeObject(myClass1));
			//Type dyType=DynamicFieldExample.AddFieldToType(typeof(MyClass),"age");
			//MyClass myClass = new MyClass();
           
			//Console.WriteLine(JsonConvert.SerializeObject(myClass));


   //         HttpTest.Test();
   //         SimpleEnum e = SimpleEnum.Yes;
   //         Enum e1= SimpleEnum.Yes;
   //         Type type=typeof(SimpleEnum);
			//Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd")}-{DateTime.Now.ToString("yyyy-MM-dd")}");
   //         string aa = "aa";
   //        // Console.WriteLine(aa.GetHashCode("sa"));
   //         List<int> a = new List<int>();
   //         a.Add(1);
   //         Console.WriteLine( DateTime.Now.Date);
   //         HttpTest.GetIpAddressV3();
   //         //HttpTest.GetIpAddressV2();

   //         Console.WriteLine("2da privada de parque nara 142, colonia colinas de parque,En la privada de atras del autolavado el trapazo,San Luis Potosi,San Luis Potosi,Mexico,78294".Length);
   //         Console.WriteLine(DateTime.Now.ToString("yyyy-MM"));
   //         Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd"));

   //         SecurityTest.TestRSA2();

			// listType.MakeGenericType(listType.GenericTypeArguments[0]);

			ExtensionVerifyParameterTest verify = new ExtensionVerifyParameterTest();
            verify.ParameterVerifyTest();
			

			List<MenuView1>menus= new List<MenuView1>();
			menus.Add(new MenuView1());
			menus =ConvertTreeExtension.ConvertTree<MenuView1,string>(menus);

            List<Type> types = new List<Type>();

            types.Add(typeof(int[]));
			types.Add(typeof(List<int>));
			types.Add(typeof(List<int>));

            foreach (var item in types)
            {
                Console.WriteLine(item.IsArray);
                Console.WriteLine(item.Name);
            }
                

            Worker.SetWorkId(1);
            Console.WriteLine(Worker.GetId());
            Worker.SetWorkId(2);
			Console.WriteLine(Worker.GetId());

			int d =(int)Math.Pow(2, 31);

            List<long> ids=new List<long>();
            List<Task> tasks=new List<Task>();
            for (int i = 0; i < 10; i++)
            {
                Task task = Task.Run(() =>
                {
					for (int i = 0; i < 1000; i++)
					{
						long id = Worker.GetId();
						ids.Add(id);
						Console.WriteLine(id);

					}
				});

			}
            Task.Delay(2000).Wait();
            Task.WaitAll(tasks.ToArray());
         
            var copyids=ids.GroupBy(t=>t).Select(t=>  new { count = t.Count(),Id=t }).Where(t=>t.count>1).ToList();
            
            HttpTest httpTest = new HttpTest();

            httpTest.TestHttpPostFile();
            //Http().Wait();
            Console.WriteLine("Hello World!");

            Type parentType = typeof(ParentClass);
            Type childType = typeof(ChildClass);

            Console.WriteLine(childType.IsAssignableFrom(parentType));
            Console.WriteLine(childType.IsAssignableTo(parentType));
            Console.WriteLine(parentType.IsAssignableTo(childType));

        
            //IsAssignableFrom


        }

        public static async Task Http()
        {
         
        }
    }

    public class MyDoc
    {
        public int Id { get; set; }
        public string User { get; set; }
        public string Message { get; set; }
        //Id = 1,
                //User = "flobernd",
                //Message = "Trying out the client, so far so good?"
    }

    public class SnowFlakeEntity
    {
        public int Id { get; set; }
        public long SnowId { get; set; }
    }
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           